import json
import requests

url = "http://127.0.0.1:8000"
url_api = f"{url}/test"
data = {"name": "lilisi", "age": 18}

# 测试1: /test
# resp = requests.put(url_api, data=data) # NG
# resp = requests.put(url_api, data=json.dumps(data)) # NG
# resp = requests.put(url_api, json=data) # NG

# 测试2: /test_v2
url_api = f"{url}/test_v2"
# resp = requests.put(url_api, data=data) # NG
resp = requests.put(url_api, data=json.dumps(data))  # OK
resp = requests.put(url_api, json=data)  # OK
print(f"recv:[{resp.status_code}] {resp.text}")
